Auto merge of #1283 - alexcrichton:bad-error, r=huonw
authorbors <bors@rust-lang.org>
Fri, 13 Feb 2015 00:24:36 +0000 (00:24 +0000)
committerbors <bors@rust-lang.org>
Fri, 13 Feb 2015 00:24:36 +0000 (00:24 +0000)
Closes rust-lang/crates.io#130

1  2 
src/cargo/ops/cargo_run.rs
tests/test_cargo_test.rs

index 2f0c601667ccbcc397a706e33f5bb3b4c85982be,6344ce4fb51b700594f0387663c8a00d3f9516a2..8c591c196c0fe97e1be46401052ea39c00921bf1
@@@ -21,12 -22,21 +21,21 @@@ pub fn run(manifest_path: &Path
              TargetKind::Example => a.is_example(),
              TargetKind::Lib(_) => false,
          };
 -        let matches_name = name.as_ref().map_or(true, |n| n.as_slice() == a.get_name());
 -        matches_kind && matches_name && a.get_profile().get_env() == env &&
 -            !a.get_profile().is_custom_build()
 +        let matches_name = name.as_ref().map_or(true, |n| *n == a.name());
 +        matches_kind && matches_name && a.profile().env() == env &&
 +            !a.profile().is_custom_build()
      });
      let bin = try!(bins.next().chain_error(|| {
-         human("a bin target must be available for `cargo run`")
+         match (name.as_ref(), &target_kind) {
+             (Some(name), &TargetKind::Bin) => {
+                 human(format!("no bin target named `{}` to run", name))
+             }
+             (Some(name), &TargetKind::Example) => {
+                 human(format!("no example target named `{}` to run", name))
+             }
+             (Some(_), &TargetKind::Lib(..)) => unreachable!(),
+             (None, _) => human("a bin target must be available for `cargo run`"),
+         }
      }));
      match bins.next() {
          Some(..) => return Err(
Simple merge